<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function Fn() {
            this.x = 100;
            this.y = 200;
            this.getX = function() {
                console.log(this.x);
            }
        }
        Fn.prototype.getX = function() {
            console.log(this.x);
            // console.log(this === Fn.prototype)
        }

        Fn.prototype.getY = function() {
            console.log(this.y);
            // console.log(this + '@')
        }

        var f1 = new Fn; // 这里不加括号也可以调用函数
        var f2 = new Fn;
        console.log(f1.getX === f2.getX); //false
        console.log(f1.getY === f2.getY); // true
        console.log(f1.__proto__.getY === Fn.prototype.getY); //true
        console.log(f1.__proto__.getX === Fn.prototype.getX); //true
        console.log(f1.getX === Fn.prototype.getX); //false
        console.log(f1.constructor); //Fn
        console.log(Fn.prototype.__proto__.constructor); //Object
        f1.getX(); //100
        f1.__proto__.getX(); //undefined f1.__proto__就是Fn.prototype 所以这是的this是Fn.prototype  //一定要记住
        f2.getY(); //200 f2里面没有getY方法,往上找(__proto__) 里面有getY,但是此时的this为f2(可以看做getY临时成为了f2的方法) //一定要记住
        Fn.prototype.getY(); //undefined
    </script>
</body>

</html>